package fr.afcepf.ticketing.service;

import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import fr.afcepf.ticketing.dao.TypeDao;
import fr.afcepf.ticketing.domain.Type;

@Stateless
public class TypeServicesBean implements TypeServices {
	
	@EJB
	private TypeDao ejbTypeDao;

	public List<Type> getTypeByCatalog(long id){
		return (List<Type>) ejbTypeDao.allTypes(id);
		
	}
	
	@Override
	public Type getTypeById(long id) {
		return ejbTypeDao.getEntityByPk(id);
	}
	
	@Override
	public void updateType(Type type) {
		ejbTypeDao.updateEntity(type);

	}

	@Override
	public void deleteType(long id) {
		ejbTypeDao.deleteEntityFromPk(id);

	}

	@Override
	public long insertNewType(Type type) {
		ejbTypeDao.createEntity(type);
		return type.getId();
	}

}
